﻿/*
 * Created by SharpDevelop.
 * User: Jack Brinegar
 * Date: 1/31/2013
 * Time: 7:56 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace AdminDesktop
{
	/// <summary>
	/// Static Utility class for common functions.
	/// </summary>
	static class Utility
	{	
		/// <summary>
		/// Converts a string to Title Case (Proper Case)
		/// </summary>
		/// <param name="s"></param>
		/// <returns>string</returns>
		public static String TitleCaseString(String s)
		{
		    if (s == null) return s;
		
		    String[] words = s.Split(' ');
		    for (int i = 0; i < words.Length; i++)
		    {
		        if (words[i].Length == 0) continue;
		
		        Char firstChar = Char.ToUpper(words[i][0]); 
		        String rest = "";
		        if (words[i].Length > 1)
		        {
		            rest = words[i].Substring(1).ToLower();
		        }
		        words[i] = firstChar + rest;
		    }
		    return String.Join(" ", words);
		}
	}
}
